#ifndef NAMECALLER_H
#define NAMECALLER_H

#include <QList>
#include <QString>
#include <QObject>
#include <QWidget>
#include <QTimer>
#include <QRandomGenerator>
#include <QDir>
#include <QDebug>
#include <QByteArray>
#include <QTime>
#include <QRegularExpression>
#include "uchardet/uchardet.h"

class nameCaller : public QObject
{
    Q_OBJECT

public:
    nameCaller(QObject *parent = nullptr);
    ~nameCaller();

public slots:
    void processFile(QString filePath);// 响应导入文件按钮
    void callOnceCheck(int checkState);// 根据点名一次勾选框响应
    void doCall();// 响应点名按钮

signals:
    void fileReadResult(bool isError, QString msg = "");
    void callName(QString name);
    void callOver();// 点名完成，全部已点完

private:
    void clear();

    bool callOnce = false;

    const QString nameInValidStr=QString("\\s");
    QRegularExpression nameInValidRule;   // 不合法文件名的正则规则

    QTimer *switchTime;
    QRandomGenerator nameRandomGen;
    quint32 selectNameIndex = 0;

    QList<QString> strListImport;

    bool doingCall = false;

private slots:
    void timeOutCall();

};
#endif // NAMECALLER_H
